package com.xxxx.server.controller;

import com.xxxx.server.entity.Notice;
import com.xxxx.server.pojo.RespBean;
import com.xxxx.server.pojo.RespPageBean;
import com.xxxx.server.service.impl.CourseServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 通知管理
 * @author: Honors
 * @create: 2021-11-17
 */
@Api(tags = "通知管理")
@RestController
@RequestMapping("/notice")
public class NoticeController {

    @Resource
    private CourseServiceImpl courseServiceImpl;

    @ApiOperation(value = "发布通知")
    @PostMapping("/addOrUpdate")
    public RespBean addOrUpdate(
            @RequestBody Notice notice) {
        return courseServiceImpl.addOrUpdateNotice(notice);
    }

    @ApiOperation(value = "删除通知")
    @DeleteMapping("/delete")
    public RespBean delete(
            @RequestParam Integer nicId) {
        return courseServiceImpl.deleteNotice(nicId);
    }

    @ApiOperation(value = "通知分页")
    @GetMapping("/page")
    public RespPageBean getNoticePage(
            @ApiParam @RequestParam(defaultValue = "1") Integer currentPage,
            @ApiParam @RequestParam(defaultValue = "10") Integer size) {
        return courseServiceImpl.getNoticePage(currentPage, size);
    }

    @ApiOperation(value = "通知-学员端")
    @GetMapping("/list")
    public List<Notice> getList() {
        return courseServiceImpl.getList();
    }

    @ApiOperation(value = "通知-个人中心")
    @GetMapping("/maxNotice")
    public Notice maxNotice() {
        return courseServiceImpl.maxNotice();
    }


}
